package com.example.cloud;

import com.example.cloud.socket.WebSocketServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableCaching
@ComponentScan("com.example")
public class UserApplication {

	@Bean
	@LoadBalanced
	public RestTemplate restTemplate(){return new RestTemplate();}

	public static void main(String[] args) {
		ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(UserApplication.class, args);
		//解决WebSocket不能注入的问题
		WebSocketServer.setApplicationContext(configurableApplicationContext);
	}
}
